<?php
/**
 * Created by jinqiang on 2024/8/26 16:50.
 * Copyright (c) 2024, Your Company. All rights reserved.
 */


namespace App\Http\Controllers\Soa;


use App\Http\Controllers\Controller;
use App\Http\Services\Soa\PriceOrderService;
use Illuminate\Http\Request;

class PriceOrderController extends Controller
{
    //核价单列表
    public function list(Request $request, PriceOrderService $priceOrderService)
    {
        $this->validate($request, [
            'page' => 'required',
            'limit' => 'required'
        ]);
        $param = $request->all();
        $res = $priceOrderService->search($param);
        return result($res);
    }

    //核价单审核列表
    public function checkList(Request $request, PriceOrderService $priceOrderService)
    {
        $this->validate($request, [
            'page' => 'required',
            'limit' => 'required'
        ]);
        $param = $request->all();
        $res = $priceOrderService->searchCheck($param);
        return result($res);
    }

    //设置实付核价
    public function setPricingExamine(Request $request, PriceOrderService $priceOrderService)
    {
        $this->validate($request, [
            'id' => 'required',
            'pay_pricing_number' => 'required'
        ]);
        $param = $request->all();
        $res = $priceOrderService->setPricingExamine($param);
        return $res['code'] === 0 ? success("设置成功") : error($res['msg'], $res);
    }

    //核价单审核进度
    public function approvalProcess(Request $request, PriceOrderService $priceOrderService)
    {
        $this->validate($request, [
            'id' => 'required',
            'run_id' => 'required',
        ]);
        $param = $request->all();
        $res = $priceOrderService->approvalProcess($param);
        return result($res);
    }

    //提交核价审核
    public function submit(Request $request, PriceOrderService $priceOrderService)
    {
        $this->validate($request, [
            'id' => 'required'
        ]);
        $param = $request->all();
        $res = $priceOrderService->submit((Int)$param['id']);
        return $res['code'] === 0 ? success($res['msg']) : error($res['msg'], $res);
    }
}
